package com.si.ui;

import java.awt.Component;
import java.util.Map;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JPanel;

import com.si.ui.enumn.EPreviewPanel;

class PreviewPanel extends JPanel implements IWidget {

	private static final long serialVersionUID = 4941340262631583892L;

	private PreviewCanvas canvas;

	@Override
	public void initialize(final Map<String, Component> components) {
		this.buildComponents(components);
		this.buildLayout();
	}

	private void buildComponents(final Map<String, Component> components) {
		this.canvas = new PreviewCanvas();
		components.put(EPreviewPanel.Canavas.toString(), this.canvas);
	}

	private void buildLayout() {
		this.setBorder(BorderFactory.createTitledBorder("Preview"));
		final GroupLayout layout = new GroupLayout(this);
		this.setLayout(layout);
		layout.setHorizontalGroup(
				layout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(layout.createSequentialGroup()
						.addGap(110, 110, 110)
						.addComponent(this.canvas, 480, 480, 480)
		));
		layout.setVerticalGroup(
				layout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addGroup(layout.createSequentialGroup()
						.addContainerGap()
						.addComponent(this.canvas, 480, 480, 480)
						.addContainerGap())
		);
	}
}
